package com.wjm.shootgame.shoot;

import com.wjm.shootgame.shoot.img.Images;

import java.awt.image.BufferedImage;

/*
* 大敌机类
* */
public class BigAirplane extends FlyingObject{
    //速度
    public int speed;


    //构造方法初始化
    public BigAirplane(){
        this.width=92;
        this.height=110;
        this.x=(int)(Math.random()*(512-this.width));
        this.y= -this.height;
        this.speed=4;
    }


    //用于输出初始化的值
    @Override
    public String toString() {
        return "BigAirplane{" +
                "speed=" + speed +
                ", width=" + width +
                ", height=" + height +
                ", x=" + x +
                ", y=" + y +
                '}';
    }


    //用来控制获取图片的下标
    int index = 1;
    @Override
    public BufferedImage getimage() {
        if (state == LIVE){
            //返回飞机图片
            return Images.bigAirplaneImage[0];
        }else if (state == DEAD){
            //如果index长度超过数组长度，就改变它的状态从容让index不在增长
            if (index == Images.bigAirplaneImage.length){
                state = REMOVE;
            }
            //返回爆炸图片
            return Images.bigAirplaneImage[index++];
        }
        return null;
    }
}
